home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / unix / textmstr.shr / tm.hqx / Source Code ƒ / TextMaster Code / tm.c < prev    next >
Text File  |  1991-05-09  |  2KB  |  63 lines

  1. /*************************************************************************
  2.  **                                                                        **
  3.  **                                    TM                                    **
  4.  **                          TextMaster    1.4                                **
  5.  **                                                                        **
  6.  **                    By Donald Burr  --  Copyright 1991                    **
  7.  **                                                                        **
  8.  **                      Released to the Public Domain                        **
  9.  **                                                                        **
  10.  ** Version History                                                        **
  11.  **                                                                        **
  12.  ** Date        Version        Comments                                    **
  13.  ** ----        -------        --------                                    **
  14.  ** 15-Mar-91    1.0            Initial release.                            **
  15.  **                            Fixed file closure bug; it now properly        **
  16.  **                            closes files when done with them.            **
  17.  **                                                                        **
  18.  ** 09-May-91    1.4            Standardized the version number with the    **
  19.  **                            UNIX Version.  Fixed problem where it        **
  20.  **                            couldn't convert Mac -> UNIX.                **
  21.  **                                                                        **
  22.  *************************************************************************/
  23.  
  24. #include     <stdio.h>        /* Standard I/O functions */
  25. #include    <string.h>        /* BSD uses strings.h */
  26. #include    "tm.h"            /* defines for TextMaster */
  27.  
  28. void tm(thing_to_do, in, out)            /* main TextMaster function */
  29. int        thing_to_do;        /* what to do, what to do */
  30. char    *in, *out;
  31. {
  32.     char    the_input, the_output;    /* input gathered from program */
  33.     char    do_the_conversion();    /* this function does the stuff */
  34.     FILE    *infile, *outfile, *fopen();
  35.     int        fclose();
  36.     
  37.     /* Assign filenames */
  38.  
  39.         infile = fopen(in, "r");    /* open the file specified --
  40.                                         binary mode to insure correct
  41.                                         read of certain chars */
  42.         if (thing_to_do == MAC_TO_UNIX)
  43.             outfile = fopen(out, "wb");    /* to xfer to UNIX, must write
  44.                                         binary file, or else it gets
  45.                                         dumb and writes Mac EOLs */
  46.         else        /* thing_to_do == UNIX_TO_MAC) */
  47.             outfile = fopen(out, "w");
  48.             
  49.     /* Get input char-by-char */
  50.  
  51.     while ((the_input = fgetc(infile)) != EOF)  {
  52.                     /* while we've still got stuff */
  53.         the_output = do_the_conversion(the_input, thing_to_do);
  54.         fputc(the_output, outfile);
  55.                         /* Do the conversion */
  56.         }
  57.     putchar(BELL);        /* Beep to let know of completion */
  58.     printf("\nTextMaster is complete.  %s has been converted to %s.\n",
  59.             in, out);
  60.     fclose(infile);
  61.     fclose(outfile);
  62. }
  63.